blob: 36db22dc348d1d0c10f089355020c01e42efb8be (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
import Link from "next/link";
import Avatar from "../../components/Avatar"
export default function Av(props) {
console.log(props)
return (
<>
<h1><Link href="/">Go back home</Link></h1>
{<Avatar data={props.av} full={true} key={props.av.id} />}
</>
)
}
export async function getStaticProps({ params }) {
const av = await fetch(`http://localhost:3000/api/avatars/${params.id}`).then(res => res.json());
return {
props: {
av
}
}
}
export async function getStaticPaths() {
const res = await fetch(`http://localhost:3000/api/avatars`).then(res => res.json());
console.log("getStaticPaths ", res)
return {
paths: res.map(av => `/av/${av.id}`),
fallback: true,
}
}
|